package com.yun.userdemo.controllers;

import org.apache.log4j.Logger;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;

import java.text.SimpleDateFormat;
import java.util.Date;

public class ControllerConfig {

    Logger logger = Logger.getLogger(ControllerConfig.class);

    @InitBinder
    public void initBinder(WebDataBinder dataBinder){
        logger.info("initBinder ============>");
        dataBinder.registerCustomEditor(
                Date.class,
                new CustomDateEditor(new SimpleDateFormat("yyyy-MM-dd"),true));
    }
}
